import Vue from 'vue'
import Router from 'vue-router'
import home from '@/pages/home'
import goods from '@/pages/goods'
import center from '@/pages/center'
import proDetails from '@/pages/prodetail'
import center_billoflading from '@/pages/billoflading/center_billoflading'
import billinfo from '@/pages/billoflading/center_billoflading_info'
import address from '@/pages/address/center_address'
import addaddress from '@/pages/address/center_addaddress'
import Register from '@/pages/register'
import mygoods from '@/pages/mygoods/center_goods'
import MyBalance from '@/pages/balance/mybalance'
import Subsidy from '@/pages/balance/subsidy'
import Generalize from '@/pages/balance/generalize'
import presentrecord from '@/pages/balance/presentrecord'
import apply from '@/pages/balance/apply'
import Contact from '@/pages/center/contact'
import Invitation from '@/pages/center/invitation'
import Member from '@/pages/center/member'
import evaluateinfo from '@/pages/evaluate/evaluateinfo'
import Order from '@/pages/center/order'
import cordlist from '@/pages/bankcord/cordlist'
import choosecard from '@/pages/bankcord/choosebank'
import addcord from '@/pages/bankcord/addcord'
import authentication from '@/pages/authentication/authentication'
import pay from '@/pages/pay/pay'

Vue.use(Router)

export default new Router({
  mode: 'history',
  routes: [{
      path: '/',
      name: '首页',
      component: home,
      meta: {
        title: "首页",
        keepAlive: false // 不需要缓存
      }
    },
    {
      path: '/goods',
      name: '所有商品',
      component: goods,
      meta: {
        title: "所有商品",
        keepAlive: false // 不需要缓存
      }
    },
    {
      path: '/center',
      name: '我的',
      component: center,
      meta: {
        title: "我的",
        keepAlive: false // 不需要缓存
      }
    },
    {
      path: '/details/:proID',
      name: '商品详情',
      component: proDetails,
      meta: {
        title: "详情",
        keepAlive: false // 不需要缓存
      }
    },
    {
      path: '/evaluateinfo',
      name: '我的评价',
      component: evaluateinfo,
      meta: {
        keepAlive: false // 不需要缓存
      },
    },
    {
      path: '/pay',
      name: '购买',
      component: pay,
      meta: {
        keepAlive: false // 不需要缓存
      },
    },
    {
      path: '/center_billoflading',
      name: '提货单',
      component: center_billoflading,
      meta: {
        keepAlive: false // 不需要缓存
      },
    },
    {
      path: '/billinfo',
      name: '提货单详情',
      component: billinfo,
      meta: {
        keepAlive: false // 不需要缓存
      },
    },
    {
      path: '/address',
      name: '我的收货地址',
      component: address,
      meta: {
        keepAlive: false // 不需要缓存
      },
    },
    {
      path: '/addaddress',
      name: '新增地址',
      component: addaddress,
      meta: {
        keepAlive: false // 不需要缓存
      },
    },
    {
      path: '/register',
      name: '注册',
      component: Register,
      meta: {
        title: "注册",
        keepAlive: false // 不需要缓存
      },
    },
    {
      path: '/mygoods',
      name: '我的商品',
      component: mygoods,
      meta: {
        keepAlive: true // 需要缓存
      },
    },
    {
      path: '/balance',
      name: '我的余额',
      component: MyBalance,
      meta: {
        title: "我的余额",
        keepAlive: false // 不需要缓存
      }
    },
    {
      path: '/subsidy',
      name: '补贴记录',
      component: Subsidy,
      meta: {
        title: "补贴记录",
        keepAlive: false // 不需要缓存
      },
    },
    {
      path: '/generalize',
      name: '推广收益',
      component: Generalize,
      meta: {
        title: "推广收益",
        keepAlive: false // 不需要缓存
      },
    },
    {
      path: '/presentrecord',
      name: '提现记录',
      component: presentrecord,
      meta: {
        title: "提现记录",
        keepAlive: false // 不需要缓存
      },
    },
    {
      path: '/apply',
      name: '申请提现',
      component: apply,
      meta: {
        title: "申请提现",
        keepAlive: false // 不需要缓存
      },
    },
    {
      path: '/contact',
      name: '联系电话',
      component: Contact,
      meta: {
        title: "联系电话",
        keepAlive: false // 不需要缓存
      },
    },
    {
      path: '/invitation',
      name: '我的邀请',
      component: Invitation,
      meta: {
        title: "我的邀请",
        keepAlive: false // 不需要缓存
      },
    },
    {
      path: '/member',
      name: '会员福利',
      component: Member,
      meta: {
        title: "会员福利",
        keepAlive: false // 不需要缓存
      },
    },
    {
      path: '/order',
      name: '我的订单',
      component: Order,
      meta: {
        title: "我的订单",
        keepAlive: false // 不需要缓存
      },
    },
    {
      path: '/cordlist',
      name: '银行卡列表',
      component: cordlist,meta: {
        keepAlive: false // 不需要缓存
      },

    },
    {
      path: '/addcord',
      name: '新增银行卡',
      component: addcord,
      meta: {
        keepAlive: false // 不需要缓存
      },
    },
    {
      path: '/authentication',
      name: '新增银行卡',
      component: authentication,
      meta: {
        keepAlive: false // 不需要缓存
      },
    },
    {
      path: '/choosecard',
      name: '选择银行卡',
      component: choosecard,
      meta: {
        keepAlive: false // 不需要缓存
      },
    },
  ],
  // 切换页面时，都是页面顶部
  scrollBehavior(to, from, savedPosition) {
    return {
      x: 0,
      y: 0
    }
  }
})
